package com.flower.hooc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.flower.hooc.bean.pojo.entity.Cart;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;

@Component
public interface CartMapper extends BaseMapper {
    /**
     * 根据用户id查商品
     *
     * @param userId
     * @return
     */
    List<Cart> selectCarByUserId(Long userId);

    /**
     * 清空购物车
     *
     * @param userId
     * @return
     */
    int deleteCartByUid(Long userId);

    /**
     * 根据userId, courseId添加Cart数据库里的数据
     *
     * @param userId
     * @param courseId
     * @param price
     * @return
     */
    int addCart(@Param("userId") long userId, @Param("courseId") long courseId, @Param("price") BigDecimal price);

}
